#define _CRT_SECURE_NO_WARNINGS   1

#include<iostream>
#include<vector>

using namespace std;

struct ListNode
{
	int val;
	struct ListNode*next;
	ListNode(int x)
		:val(x), next(NULL){}
	ListNode()
		:val(),next(){}
};
ListNode* CreateList(int a[], int n)
{
	ListNode * rear, *s;
	ListNode *head = new ListNode;
	rear = head;
	for (int i = 0; i < n; i++)
	{
		s = new ListNode;
		s->val = a[i];
		rear->next = s;
		rear = s;
	}
	rear->next = NULL;
	return head;
}

class Solution {
public:
	ListNode* deleteNode(ListNode* head, int val) {
		ListNode* res = new ListNode;
		res->next = head;
		ListNode* pre = res;
		ListNode* cur = head;
		while (cur != NULL){
			if (cur->val == val){
				pre->next = cur->next;
				break;
			}
			pre = cur;
			cur = cur->next;
		}
		return res->next;
	}
};

int main()
{
	Solution sol;
	int num;
	vector<int>a;
	while (cin >> num)
	{
		a.push_back(num);
		if (cin.get() == '\n')
			break;
	}
	int *b;
	b = new int[a.size()];
	for (int i = 0; i < a.size(); i++)
	{
		b[i] = a[i];
	}
	int val;
	cin >> val;
	ListNode *ph = sol.deleteNode(CreateList(b, a.size()), val);

	ListNode *p = ph;
	while (p)
	{
		cout << p->val << "  ";
		p = p->next;
	}
	cout << endl;
}
